<?php

namespace app\admin\controller\customer;

use app\admin\controller\Base;
use think\Db;

/**
 * 用户组管理
 * Class GroupController
 * @package app\admin\controller\auth
 */
class Order extends Base
{

    public function index()
    {
        return view();
    }


    public function lists()
    {
        $map = array();
        $data = array();
        $post = $this->request->param();
        $data['count'] = DB::view('product_order', 'id,c_time,product_id,product_info_id,uid,price,day,order_id,status,product_run_id')
            ->view('user', 'company', 'product_order.uid=user.id')
            ->view('product', 'title', 'product_order.product_id=product.id')
            ->view('product_info', ['title' => 'info_title'], 'product_order.product_info_id=product_info.id')
            ->where($map)
            ->count();
        $data['data'] = DB::view('product_order', 'id,c_time,product_id,product_info_id,uid,price,day,order_id,status,product_run_id')
            ->view('user', 'company', 'product_order.uid=user.id')
            ->view('product', 'title', 'product_order.product_id=product.id')
            ->view('product_info', ['title' => 'info_title'], 'product_order.product_info_id=product_info.id')
            ->where($map)
            // ->fetchSql(true)
            ->order('id desc')->page(input("param.page"), input('param.limit'))->select();
        $order_status = config('param.order_status');
        foreach ($data['data'] as &$info) {
            $info['c_time'] = date('Y-m-d  H:i:s', $info['c_time']);
            $info['status'] = $order_status[$info['status']];
        }
        if ($data['count'] > 0 && $data['data']) {
            $data['msg'] = '获取成功';
        } else {
            $data['msg'] = '获取数据为空';
        }
        $data['code'] = 0;
        return json($data);
    }




}